Learn R Programming

DER (version 1.3)

Kernel Density Estimation: Kernel Density Estimation (KDE)

Description

Kernel density estimation of a univariate sample using a Gaussian kernel.

Usage

kde(y, h, ncores = 1)

Value

A numeric vector of density estimates corresponding to each observation in y.

Arguments

y

A numeric vector containing the sample data.

h

A numeric value for boundwidth.

ncores

The number of cores to use. If greater than 1, parallel computing will take place. It is advisable to use it if you have many observations and or many variables, otherwise it will slow down the process. The default is 1, meaning that code is executed serially.

Author

Michail Tsagris and Christos Adam.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr and Christos Adam econp266@econ.soc.uoc.gr.

Details

The kernel density estimate (KDE) provides a smooth estimate of the probability density function of the sample data. In this implementation, the KDE is evaluated only at the observed sample points themselves.

Examples

Run this code
set.seed(123)
y <- rnorm(200)
dens <- kde(y, h = 1)

Run the code above in your browser using DataLab